InĀ [1]:
#Question 1
using JuMP, Cbc
m=Model()
@variable(m, x1 >= 0)
@variable(m, x2 >= 0)
@variable(m, x3 >= 0)
@objective(m, Max, -x1+2x2+0.5x3)
@constraint(m, constraint1, 2x1-x2 >= 1)
@constraint(m, constraint2, 2x1+3x3 <= 3)
set_optimizer(m, Cbc.Optimizer)
optimize!(m)
#display the solution
println("optimal value of x1: ", value(x1))
println("optimal value of x2: ", value(x2))
println("optimal value of x3: ", value(x3))
println("optimal objective: ", objective_value(m))
optimal value of x1: 1.5 optimal value of x2: 2.0 optimal value of x3: 0.0 optimal objective: 2.5 Presolve 0 (-2) rows, 0 (-3) columns and 0 (-4) elements Optimal - objective value 2.5 After Postsolve, objective 2.5, infeasibilities - dual 0 (0), primal 0 (0) Optimal objective 2.5 - 0 iterations time 0.002, Presolve 0.00
InĀ [Ā ]:
Question 2-1 Maximum (5x1+4x2) becomes optimal at x1 = 3 and x2 = 1.5
Question 2-2 Maximum (10x2) becomes optimal at x2 = 2
InĀ [Ā ]:
InĀ [2]:
#Question 3
Maximize
30x1+60x2+50x3 #Maximize Money
subject to (Constraints)
x1, x2, x3 >= 0
40x1 + 20x2 + 30x3 <= 900 #Tulips
15x1 + 25x2 + 30x3 <= 700 #Daffodils
10x1 + 15x2 + 20x3 <= 500 #Hyacinths
UndefVarError: `Maximize` not defined
InĀ [Ā ]:
InĀ [3]:
#Question 4-1
Minimize
8x1 + 4x2 #We want to minimize cost
Subject to (Constraints)
5x1+15x2 >= 50 #Carbohydrates
50x1 + 5x2 >= 40 #Protein
15x1 + 2x2 >= 60 #Fat
x1 >= 0
x2 >= 0
UndefVarError: `Minimize` not defined
QUESTION 4-2) Professor Smith's Friend gets to eat 0.8 steaks, and 0 french fries
InĀ [Ā ]:
Question 5-1) This LP becomes optimal when x1 = 0,10 & x2 = -1,1
Question 5-2) This LP has infinite solutions. Due to it's constraints, it has an infinite amount of solutions.
Question 5-3 Part A) LP becomes optimal @ x1 = 10 and x2 = 1
Question 5-3 Part B) Unique Optimal Solution same as part A
InĀ [5]:
#Question 5-4
Answer = "We call this Linear Program with this objective UNBOUNDED, as the LP can reach INFINITY"
Answer
Out[5]:
"We call this Linear Program with this objective constraints UNBOUNDED, as the LP can reach INFINITY"